<template>
  <div class="detail">
    <!-- 对于布尔值属性来说传值的时候写了就是true -->
    <HmHeader showArrow @clickLeft="fn"
      >面经详情
      <template #right>搜索</template>
    </HmHeader>
    <h1>{{ obj.stem }}</h1>
    <div class="info">
      <span>{{ obj.createdAt }}</span>
      <span>|</span>
      <span>{{ obj.views }} 浏览量</span>
      <span>|</span>
      <span>{{ obj.likeCount }} 点赞数</span>
    </div>

    <div class="qian">
      <img :src="obj.creatorAvatar" alt="" />
      <span>{{ obj.creatorName }}</span>
    </div>

    <div class="content">
      {{ obj.content }}
    </div>
  </div>
</template>

<script>
import axios from "axios";

// import HmHeader from "../components/HmHeader.vue";
export default {
  name: "HmDetail",
  data() {
    return {
      obj: {},
    };
  },
  created() {
    // console.log(this.$route.params.id);
    this.getDetail(this.$route.params.id);
  },

  methods: {
    fn() {
      this.$router.back();
    },
    async getDetail(id) {
      if (!id) return;
      const res = await axios({
        url: "https://mock.boxuegu.com/mock/3083/articles/" + id,
      });
      console.log(res.data.result);
      this.obj = res.data.result;
    },
  },
};
</script>

<style lang="less" scoped>
.qian {
  display: flex;
  align-items: center;

  img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
}

.content {
  text-indent: 2em;
}
</style>
